package com.ssy.lingxi.order.controller.feign;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.api.model.vo.request.*;
import com.ssy.lingxi.order.api.model.vo.response.*;
import com.ssy.lingxi.order.service.feign.IOrderFeignService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * （内部）流程规则配置查询接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-25
 */
@RestController
@RequestMapping("/order/feign")
public class OrderFeignController {
    @Resource
    private IOrderFeignService orderFeignService;

    /**
     *  查询（供应）会员交易流程规则配置
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/trade/process/find", method = RequestMethod.POST)
    public Wrapper<OrderTradeProcessFeignDetailVO> findVendorTradeProcess(@RequestBody @Valid OrderTradeProcessFeignVO feignVO) {
        return orderFeignService.findVendorTradeProcess(feignVO);
    }

    /**
     * 查询（采购）会员采购流程规则配置
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/purchase/process/find", method = RequestMethod.POST)
    public Wrapper<OrderPurchaseProcessFeignDetailVO> findBuyerPurchaseProcess(@RequestBody @Valid OrderPurchaseProcessFeignVO feignVO) {
        return orderFeignService.findBuyerPurchaseProcess(feignVO);
    }

    /**
     * 查询平台后台 - 会员支付策略设置
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/platform/payment/find", method = RequestMethod.POST)
    public Wrapper<List<PlatformPayTypeFeignDetailVO>> findPlatformPayments(@RequestBody @Valid OrderMemberFeignVO feignVO) {
        return orderFeignService.findPlatformPayments(feignVO);
    }

    /**
     * 查询支付参数
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/payment/parameter/find", method = RequestMethod.POST)
    public Wrapper<PaymentParameterFeignDetailVO> findPaymentParameters(@RequestBody @Valid OrderPayParameterFeignVO feignVO) {
        return orderFeignService.findPaymentParameters(feignVO);
    }

    /**
     * 查询支付参数（直接查询平台支付参数配置）
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/platform/payment/parameter/find", method = RequestMethod.POST)
    public Wrapper<PaymentParameterFeignDetailVO> findPlatformPaymentParameters(@RequestBody @Valid OrderPayChannelFeignVO feignVO) {
        return orderFeignService.findPlatformPaymentParameters(feignVO);
    }

    /**
     * 查询支付参数（直接查询会员支付参数配置）
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/payment/parameter/find", method = RequestMethod.POST)
    public Wrapper<PaymentParameterFeignDetailVO> findMemberPaymentParameters(@RequestBody @Valid OrderPayParameterFeignVO feignVO) {
        return orderFeignService.findMemberPaymentParameters(feignVO);
    }

    /**
     * 售后服务 - 更新订单商品的换货、退货、维修数量、退款金额
     * @param afterSales 接口参数
     * @return 更新结果
     */
    @RequestMapping(value = "/after/sale/update", method = RequestMethod.POST)
    public Wrapper<Void> updateAfterSaleOrderProduct(@RequestBody @Valid List<OrderAfterSaleVO> afterSales) {
        return orderFeignService.updateAfterSaleOrderProduct(afterSales);
    }

    /**
     * 售后服务 - 更新订单商品的实际退款金额
     * @param orderReturnAmountUpdateVO 退款信息VO
     * @return 更新结果
     */
    @RequestMapping(value = "/after/update/refund/amount", method = RequestMethod.POST)
    public Wrapper<Void> updateAfterSaleOrderProductAmount(@RequestBody OrderReturnAmountUpdateVO orderReturnAmountUpdateVO){
        return orderFeignService.updateAfterSaleOrderProductAmount(orderReturnAmountUpdateVO);
    }

    /**
     * 售后服务 - 查询订单商品的已支付金额，换货、退货、维修数量、退款金额
     * @param orderProductIds 订单商品Id列表
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/find", method = RequestMethod.POST)
    public Wrapper<List<OrderAfterSaleProductFeignDetailVO>> findAfterSaleOrderProducts(@RequestBody @Valid List<OrderProductIdFeignVO> orderProductIds) {
        return orderFeignService.findAfterSaleOrderProducts(orderProductIds);
    }

    /**
     * 售后服务 - 批量查询订单外部状态
     * @param feignVO 订单Id列表
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/status/find", method = RequestMethod.POST)
    public Wrapper<List<OrderAfterSaleStatusVO>> findAfterSaleOrderStatuses(@RequestBody @Valid OrderIdsFeignVO feignVO) {
        return orderFeignService.findAfterSaleOrderStatuses(feignVO);
    }

    /**
     * 售后服务 - 根据合同Id查询订单列表
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/contract/find", method = RequestMethod.POST)
    public Wrapper<List<OrderAfterSaleOrderContractFeignVO>> findAfterSaleOrderContracts(@RequestBody @Valid OrderContractFeignVO feignVO) {
        return orderFeignService.findAfterSaleOrderContracts(feignVO);
    }

    /**
     * 售后能力 - 查询支付记录列表
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/payment/find", method = RequestMethod.POST)
    public Wrapper<List<OrderAfterSalePaymentFeignDetailVO>> findAfterSaleOrderPayments(@RequestBody @Valid OrderIdsFeignVO feignVO) {
        return orderFeignService.findAfterSaleOrderPayments(feignVO);
    }

    /**
     * 物流能力 - 确认物流单后，更新订单的物流单号
     * @param feignVO 接口参数
     * @return 更新结果
     */
    @RequestMapping(value = "/logistics/update", method = RequestMethod.POST)
    public Wrapper<Void> updateOrderLogisticsNo(@RequestBody @Valid OrderUpdateLogisticsNoFeignVO feignVO) {
        return orderFeignService.updateOrderLogisticsNo(feignVO);
    }

    /**
     * 加工能力 - 更新订单商品加工数量
     * @param feigns 接口参数
     * @return 更新结果
     */
    @RequestMapping(value = "/enhance/update", method = RequestMethod.POST)
    public Wrapper<Void> updateOrderProductEnhanceCount(@RequestBody @Valid List<OrderUpdateEnhanceFeignVO> feigns) {
        return orderFeignService.updateOrderProductEnhanceCount(feigns);
    }

    /**
     * 结算服务 - 查询订单发票信息
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/settle/account/invoice/find", method = RequestMethod.POST)
    public Wrapper<OrderSettleAccountInvoiceFeignDetailVO> findSettleAccountInvoiceDetail(@RequestBody @Valid OrderNoFeignVO feignVO) {
        return orderFeignService.findSettleAccountInvoiceDetail(feignVO);
    }

    /**
     * 会员服务 - 订单评论完成后，更改订单评论状态
     * @param feignVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/member/comment", method = RequestMethod.POST)
    public Wrapper<Void> updateOrderComment(@RequestBody @Valid OrderCommentFeignVO feignVO) {
        return orderFeignService.updateOrderComment(feignVO);
    }

    /**
     * 支付服务 - 订单服务回调
     * @param callbackFeignVO 回调参数
     * @return 操作结果
     */
    @RequestMapping(value = "/pay/callback", method = RequestMethod.POST)
    public Wrapper<Void> orderPayCallback(@RequestBody @Valid OrderPayCallbackFeignVO callbackFeignVO) {
        return orderFeignService.orderPayCallback(callbackFeignVO);
    }

    /**
     * 售后服务 - 订单会员信息校验
     * @param checkVO 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/after/sale/order/member/check", method = RequestMethod.POST)
    public Wrapper<Boolean> checkAfterSaleOrderMember(@RequestBody @Valid CheckOrderMemberAfterSaleVO checkVO) {
        return orderFeignService.checkAfterSaleOrderMember(checkVO);
    }

    /**
     * 结算服务 - 平台结算支付方式列表
     * @return 平台结算支付方式列表
     */
    @RequestMapping(value = "/settle/accounts/settlement/type/list", method = RequestMethod.POST)
    public Wrapper<List<PlatformSettlementTypeVO>> findSettlementType() {
        return orderFeignService.findSettlementTypeByStatusEqualEnable();
    }

    /**
     * 结算服务 - 平台结算渠道方式列表
     * @return 平台结算渠道方式列表
     */
    @RequestMapping(value = "/settle/accounts/settlement/channel/list", method = RequestMethod.POST)
    public Wrapper<List<MemberSettleChannelVO>> findSettlementChannel(@RequestBody @Valid MemberSettleChannelQueryVO request) {
        return orderFeignService.findSettlementChannel(request);
    }

    /**
     * 查询平台规则配置
     * @param feignVO 查询条件
     * @return 查询结果
     */
    @RequestMapping(value = "/rules/find", method = RequestMethod.POST)
    public Wrapper<List<OrderRuleDetailVO>> findOrderRules(@RequestBody OrderRuleDetailFeignVO feignVO) {
        return orderFeignService.findOrderRules(feignVO);
    }

    /**
     * 营销服务 - 查询订单商品信息
     * @param feignVO 查询条件
     * @return 查询结果
     */
    @RequestMapping(value = "/marketing/products/find", method = RequestMethod.POST)
    public Wrapper<List<OrderMarketingDetailVO>> findOrderMarketingProducts(@RequestBody OrderMarketingFeignVO feignVO) {
        return orderFeignService.findOrderMarketingProducts(feignVO);
    }

    /**
     * 会员服务 - 查询订单供应会员会员Logo、或店铺Logo、或自营商城Logo
     * @param feignVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/vendor/logo", method = RequestMethod.POST)
    public Wrapper<List<OrderVendorLogoFeignVO>> findOrderVendorLogo(@RequestBody OrderFeignIdsVO feignVO){
        return orderFeignService.findOrderVendorLogo(feignVO);
    }

    /**
     * 结算服务 - 新增请款单-查询请款类型和付款方过滤采购订单数据
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/settle/buyer/order/page", method = RequestMethod.POST)
    public Wrapper<PageData<OrderBuyerSettleQueryVO>> pageSettleBuyerOrders(@RequestBody @Valid OrderBuyerSettlePageVO pageVO) {
        return orderFeignService.pageSettleBuyerOrders(pageVO);
    }

    /**
     * 结算服务 - 付款完成后修改订单收发货记录状态为已结算
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/settle/deliveries/update", method = RequestMethod.POST)
    public Wrapper<Void> updateOrderDeliveries(@RequestBody @Valid OrderUpdateDeliveriesFeignVO feignVO) {
        orderFeignService.updateOrderDeliveries(feignVO);
        return Wrapper.success();
    }

    /**
     * 结算服务 - 协同对账 - 对账单生成请款单采购订单数据
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/settle/reconciliation/buyer/order", method = RequestMethod.POST)
    public Wrapper<List<OrderBuyerSettleReconciliationFeignVO>> settleReconciliationBuyerOrders(@RequestBody @Valid OrderFeignIdsVO feignVO) {
        return orderFeignService.settleReconciliationBuyerOrders(feignVO);
    }

    /**
     * “售后服务” - 查询订单商品使用“平台优惠券”后的优惠抵扣金额
     * @param feignVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/platform/coupon/find", method = RequestMethod.POST)
    public Wrapper<List<OrderProductCouponFeignVO>> findOrderProductCouponAmounts(@RequestBody @Valid OrderFeignIdsVO feignVO) {
        return orderFeignService.findOrderProductCouponAmounts(feignVO);
    }

    /**
     * “搜索服务” - 批量查询会员满额包邮配置
     * @param feignVO
     * @return
     */
    @RequestMapping(value = "/search/member/free/express/config/list", method = RequestMethod.POST)
    Wrapper<List<OrderFreeExpressConfigVO>> getOrderFreeExpressConfigList(@RequestBody @Valid OrderFreeExpressFeignVO feignVO){
        return orderFeignService.getOrderFreeExpressConfigList(feignVO);
    }

    /**
     * “搜索服务” - 批量查询会员积分抵扣订单金额配置
     * @param feignVO
     * @return
     */
    @RequestMapping(value = "/search/member/score/config/list", method = RequestMethod.POST)
    Wrapper<List<OrderScoreConfigVO>> getOrderScoreConfigList(@RequestBody @Valid OrderScoreFeignVO feignVO){
        return orderFeignService.getOrderScoreConfigList(feignVO);
    }

    /**
     * 根据物料信息查询订单(商品能力- 物料价格库)
     * @author lxc
     * @date 2022/4/2
     **/
    @RequestMapping(value = "/goodsPrice/by/goods", method = RequestMethod.POST)
    Wrapper<OrderPriceQueryVO> goodsPriceByGoods(@RequestBody @Valid OrderPriceQueryRequest request){
        return orderFeignService.goodsPriceByGoods(request);
    }
}


